//
//  NineBlockBoxView.m
//  Menu
//
//  Created by trimad on 11-11-11.
//  Copyright 2011 Trimad Group. All rights reserved.
//

#import "NineBlockBoxView.h"
#import "LayoutItemView.h"

@implementation NineBlockBoxView

- (id)initWithFrameAndItems:(CGRect)frame items:(NSArray *) items {
	self = [super initWithFrameAndItems:frame items:items];
	
    if (self) {
		int count = [items count];
		int x, y;
		LayoutItemView *layoutItemView;
		
		for (int i = 0; i < count; i++) {
			x = 15 + (i - (i / 3) * 3) * 220;
			y = 0 + (i / 3) * 280;
			layoutItemView = [[[NSBundle mainBundle] loadNibNamed:@"NineBlockBoxItemView" owner:self options:nil] 
							  objectAtIndex:0];
			layoutItemView.frame = CGRectMake(x, y, 215, 275);
			[layoutItemView activate:[items objectAtIndex:i]];
			[self addSubview: layoutItemView];
		}
	}
	return self;
}

@end
